using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using System.IO;

namespace OpenComposite.EII
{
	public partial class FormTextExt : Form
	{
		public FormTextExt()
		{
			InitializeComponent();

			txtMain.SetHighlighting("C#");
		}

		public string TextEx
		{
			get { return txtMain.Text; }
			set { txtMain.Text = value; }
		}
		public string DefaultExt
		{
			get { return dlgSaveFile.DefaultExt; }
			set { dlgSaveFile.DefaultExt = value; }
		}
		public string Filter
		{
			get { return dlgSaveFile.Filter; }
			set { dlgSaveFile.Filter = value; }
		}
		public string FileName
		{
			get { return dlgSaveFile.FileName; }
			set { dlgSaveFile.FileName = value; }
		}

		private void saveToolStripButton_Click(object sender, EventArgs e)
		{
			if ( dlgSaveFile.ShowDialog() == DialogResult.OK ) {
				Stream s = null;
				if ( ( s = dlgSaveFile.OpenFile() ) != null ) {
					using ( StreamWriter sw = new StreamWriter(s) ) {
						sw.Write(this.TextEx);
						sw.Flush();
					}
					s.Close();
				}
				this.Close();
			}
		}
	}
}